#pragma once

#include "Utils.hpp"

#include <iterator>
#include <memory>
#include <vector>

class CField;

////////////////////////////////////////////////////////////////
// CSphere
//
/// Sphere of field
class CSphere
{
public:
	/// Result of applying sphere
	class Result
	{
		friend class CSphere;
		
	public:
		typedef std::vector<position_t> list_t;
		const list_t& Mobs;

	public:
		void print() const;
		void print(const CField& f, 
			bool print_info = true) const;

	private:
		/// Constructor. Inhibit constructing from outside.
		Result(CSphere&, list_t&);

	private:
		uint x, y, w, h, fx, fy; // for caching
		const CSphere& s;
		std::auto_ptr<list_t> mobs;
	};

public:
	template<unsigned int N>
	CSphere(char range_area[N][N]);
	CSphere(uint range_length);

	Result apply(const CField& f, uint center_x, uint center_y);
	const char get(uint x, uint y) const;
	const uint getRangeLength();

	void print() const;
	void printWithRuler() const;

private:
	void printLine(uint) const;

private:
	const char* const range;
	uint width;
};

